# 设计三个类，分别为圆类、长方形类和三角形类。
# 圆类的数据属性为半径，长方形类的数据属性为长和宽，三角形类的数据属性为三边a、b、c，请为每个类编写构造方法和计算周长和面积的方法，其中三角形类的面积用海伦公式计算。在main中对三个类进行实例化其相应的对象，计算各自的周长和面积。
import math

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height
    def getArea(self):
        area = self.width*self.height
        return area
    def getPerimeter(self):
        perimeter = self.width*2 + self.height*2
        return perimeter
    
class Triangle:
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c
    def getArea(self):
        p = (self.a + self.b + self.c) / 2
        area = math.sqrt(p*(p - self.a)*(p - self.b)*(p - self.c))  
        return area
    def getPerimeter(self):
        perimeter = self.a + self.b + self.c
        return perimeter
    
class Roundness:
    def __init__(self, r):
        self.r = r
    def getArea(self):
        area = math.pi * pow(self.r, 2)
        return area
    def getPerimeter(self):
        perimeter = 2 * math.pi * self.r
        return perimeter
    
if __name__ == "__main__":
    obj1 = Rectangle(3, 2)
    obj2 = Triangle(3, 4, 5)
    obj3 = Roundness(2)
    print(obj1.getArea())
    print(obj1.getPerimeter())
    print(obj2.getArea())
    print(obj2.getPerimeter())
    print(obj3.getArea())
    print(obj3.getPerimeter())